let db = require('../db.js');

//获取公司信息

exports.getCompany = async function () {
    let sql = `
  SELECT id,name,address FROM  company
  `
    let data = await db.query(sql);
    return data[0][0];
}

//生成公司信息
exports.insertCompany = async function (name, address) {
    let sql = `
    INSERT  INTO  company(name,address)
    VALUE(:name,:address)
    `
    let data = await db.query(sql, {
        name,
        address
    });
    return data[0]
}

//修改公司信息
exports.updateCompany = async function (id, name, address) {
    let sql = `
    UPDATE company SET 
    name=:name,
    address =:address
    where id =:id
    `
    let data = await db.query(sql, {
        id,
        name,
        address
    });
    return data[0]
}

//获取数据备份默认设置

exports.getBackupStatus = async function(){
    let sql =`
     SELECT *FROM  backup_sql 
    `
    let data = await db.query(sql);
    return data[0][0];
}

//更改数据备份设置

exports.updateBackupSql = async function(id,backupStatus){
  let sql=`
   UPDATE  backup_sql  SET  backupStatus=:backupStatus
   where id =:id
  
   `
   let data  = await db.query(sql,{id,backupStatus});
   return data[0];


}